package com.wie.controller;

import com.wie.domain.entity.Result;
import com.wie.domain.vo.SensorDataVO;
import com.wie.service.SensorDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/sensorData")
public class SensorController {

    @Autowired
    private SensorDataService sensorDataService;

    /**
     * 获取传感器信息
     * 湿度、二氧化碳含量、有害气体检测、温度
     * @return
     */
    @GetMapping("/get")
    public Result<SensorDataVO> getSensorData () throws IOException {
        log.info("获取传感器信息");
        SensorDataVO sensorDataVO = sensorDataService.fetchSensorData();
        return Result.success(sensorDataVO);
    }
}
